//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Math Helper
// Math.h
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#ifndef TEXT_H
#define TEXT_H

#include <d3dx9.h>
#include "Drawable.h"

class Text : public Drawable
{
public:
	Text();
	~Text();

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For creating the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, a path passed into the function. This can either be used for
	// the texture file name, or for a mesh's file name.
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	virtual bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName);

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For rendering the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	virtual void Render(float a_dt, IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

	//////////////////////////////////////////////////////////////////////////
	// OVERLOADED VIRTUAL - Inherited from Drawable
	// Can be used instead of several set paramaters. This initiates everything
	// with all the settings being passed in as paramaters.
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, filename for the texture, NULL is passed in here
	// fontSize, size of the font, by default 22
	// a_pString, String to be added to the Text object
	// a_x, x position of the text
	// a_y, y position of the text
	// a_color, colour of the text, by default it is white
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	virtual bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName, int fontSize = 22, const char* a_pString = '\0', int a_x = 0, int a_y = 0, D3DCOLOR a_color = D3DCOLOR_XRGB(255,255,255));

	//////////////////////////////////////////////////////////////////////////
	// Set the text displayed by this object
	//
	// Paramaters:
	// a_pString, const char pointer, string used to set to member data string
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void SetText(const char* a_pString);

	//////////////////////////////////////////////////////////////////////////
	// Set the position of the text
	//
	// Paramaters:
	// a_x, x position of the text
	// a_y, y position of the text
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void SetPosition(float a_x, float a_y);

	//////////////////////////////////////////////////////////////////////////
	// Set the colour of the text being drawn
	//
	// Paramaters:
	// a_color, new colour to set as the text colour
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void SetColor(D3DCOLOR a_color);

private:
	//Font, used to create the text
	LPD3DXFONT m_pFont;

	//Bounding rect for the text
	RECT m_fontRect;

	//String buffer
	char* m_pString;

	//Colour of the string
	D3DCOLOR m_color;

	//Size of the font
	int m_fontSize;
};

#endif //TEXT_H